/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.fee.core.service.processor.calculate;

import cn.hutool.core.util.ObjectUtil;
import info.peigen.hotpot.business.fee.core.domain.Fee;
import info.peigen.hotpot.business.fee.core.domain.action.FeeConverter;
import info.peigen.hotpot.business.fee.core.service.processor.base.AbstractFeeServiceProcessor;
import info.peigen.hotpot.business.fee.facade.command.result.FeeResult;
import info.peigen.hotpot.common.service.base.processor.Processor;
import info.peigen.hotpot.common.service.base.processor.ProcessorServiceContext;
import org.noear.solon.annotation.Component;

/**
 * <b>(CalculateFeeProcessor)</b>
 *
 * @author LiHai
 * @version 1.0.0
 * @since 2022/9/6
 */
@Component
public class CalculateFeeResultProcessor extends AbstractFeeServiceProcessor implements Processor {
    @Override
    public Integer level() {
        return 90;
    }

    @Override
    public void execute(ProcessorServiceContext serviceContext) {
        Fee domain = (Fee) serviceContext.getDomain();
        if (ObjectUtil.isNotNull(domain)) {
            FeeResult result = (FeeResult) serviceContext.getResult();
            result.fromSuccess(FeeConverter.convert(domain));
        }
    }
}